﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using KillBill.Business.Entities;
using KillBill.Common.View;
using KillBill.Presentation.Common.WindowsForms.View;
using KillBill.Presentation.Modules.Products.IView;
using KillBill.Presentation.Modules.Products.Presenter;

namespace KillBill.Presentation.Modules.Products.View
{
    public partial class ProductMainView : KillBillWinFormView, IProductMain
    {
        public ProductMainView()
        {
            InitializeComponent();
            Presenter = new ProductMainPresenter(this);
        }

        public ProductMainPresenter Presenter { get; set; }
        
        public List<Product> ProductList
        {
            set { productBindingSource.DataSource = value; }
        }

        public Product CurrentProduct
        {
            get
            {
                if (productBindingSource.Current != null)
                    return productBindingSource.Current as Product;
                ShowMessage(Text, "Por favor seleccione un producto", MessageOptions.Ok, MessageIcon.Exclamation);
                return null;
            }
        }

        private void nuevoToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Presenter.ShowProductAddView();
            Presenter.LoadProductList();
        }

        private void ProductMainView_Load(object sender, EventArgs e)
        {
            Presenter.LoadProductList();
            msProducts.Visible = false;
        }

        private void editarToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Presenter.ShowProductEditView();
            Presenter.LoadProductList();
        }

        private void nuevoToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            Presenter.ShowProductAddView();
            Presenter.LoadProductList();
        }

        private void editarToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            Presenter.ShowProductEditView();
            Presenter.LoadProductList();
        }
        
    }
}
